import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart';

class SixPage extends StatelessWidget {
  const SixPage({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: CustomScrollView(
        slivers: [
          SliverAppBar(
            title: Text('Flutter demo Page'),
          ),
          SliverOpacity(
            opacity: .45,
            sliver: SliverToBoxAdapter(
              child: FlutterLogo(
                size: 300,
              ),
            ),
          ),
          SliverAnimatedOpacity(
            opacity: .45,
            sliver: SliverToBoxAdapter(
              child: FlutterLogo(
                size: 300,
              ),
            ),
            duration: Duration(seconds: 1),
          ),
          SliverIgnorePointer(
            sliver: SliverToBoxAdapter(
              child: ElevatedButton(
                onPressed: () {
                  print('我被点击了');
                },
                child: Text('通过Sliver版本的SliverIgnorePointer来忽略这个按钮的点击事件'),
              ),
            ),
          ),
          SliverGrid(
            delegate: SliverChildListDelegate([
              Icon(Icons.animation),
              Icon(Icons.animation),
              Icon(Icons.animation),
              Icon(Icons.animation),
              Icon(Icons.animation),
            ]),
            gridDelegate: SliverGridDelegateWithMaxCrossAxisExtent(
              maxCrossAxisExtent: 23,
            ),
          ),
          SliverToBoxAdapter(
            child: Divider(
              thickness: 4,
              color: Colors.black,
            ),
          ),
          SliverToBoxAdapter(
            child: Text(
                '这里我使用了SliverFillRemaining来感知Sliver内部的视窗大小，从而可以让logo处在视窗的最中间',

                style: TextStyle(fontSize: 24)),
          ),
          SliverFillRemaining(
            child: Center(
              child: Container(
                  decoration: BoxDecoration(border: Border.all()),
                  child: FlutterLogo(
                    size: 300,
                  )),
            ),
          ),
          SliverToBoxAdapter(
            child: Text(
                '使用SliverLayoutBuilder，会获得一个SLiverConstraints 我们来打印出来这个constraint：'
    'I/flutter (10032): SliverConstraints(AxisDirection.down, '
    'GrowthDirection.forward, ScrollDirection.forward, '
    'scrollOffset: 0.0, remainingPaintExtent: 0.0, crossAxisExtent: 392.7, '
    'crossAxisDirection: AxisDirection.right, viewportMainAxisExtent: 872.7,'
    ' remainingCacheExtent: 46.0, cacheOrigin: 0.0)',

                style: TextStyle(fontSize: 44)),
          ),
          SliverLayoutBuilder(
              builder: (BuildContext context, SliverConstraints constraints) {
            print(constraints);
            return SliverToBoxAdapter(child: Placeholder(fallbackHeight: 2000,),);
          })
        ],
      ),
    );
  }
}
